<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录/注册</title>

    <!-- 界面样式设置 -->
    <style>
        form {
            width: 260px;
            height: 150px;
            margin: 0 auto;
            border: 1px solid #ccc;
            padding: 20px;
            background-color: azure;
        }
        
        .right {
            float: right;
        }
        
        .register {
            float: right;
            margin: 10px;
            font-size: 10px;
        }
        
        .agreement {
            float: left;
            margin: 10px 25px;
            font-size: 10px;
        }
        
        p {
            float: left;
            font-size: 10px;
        }
        
        p:nth-of-type(2) {
            position: relative;
            left: 20px;
        }
        
        .box {
            display: block;
            margin-top: 40px;
        }
        
        .reset {
            margin-left: 25px;
            border-radius: 10px;
        }
        
        .login {
            float: right;
            margin-right: 25px;
            border-radius: 10px;
        }
    </style>

    <!-- 登录操作判断 -->
    <script>
        function login() {
            // 获取用户名和密码输入框的值
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;

            // 检查复选框是否选中
            var checkbox = document.getElementById("checkbox");
            if (!checkbox.checked) {
                alert("请仔细阅读并勾选登录协议和隐私政策");
                return;
            }

            // 验证用户名和密码
            if (username === "admin" && password === "123") {
                // 加载新页面
                window.location.href = "index1.html";
            } else {
                alert("用户名或密码错误");
            }
        }
    </script>

    <!-- 注册登录页面切换 -->
    <script>
        function toggleBlocks() {
            var block1 = document.getElementById("block1");
            var block2 = document.getElementById("block2");

            if (block1.style.display === "none") {
                block1.style.display = "block";
                block2.style.display = "none";
            } else {
                block1.style.display = "none";
                block2.style.display = "block";
            }
        }
    </script>
</head>

<body>
    <div id="block1">
        <form class="display_form" action="#" method="post">
            用户名：
            <input class="right" type="text" id="username" placeholder="请输入您的用户名" maxlength="5">
            <br><br>密码：
            <input class="right" type="password" id="password" placeholder="请输入您的密码">
            <div class="register"><a href="#" onclick="toggleBlocks()">快速注册</a> | <a href="HTML5课堂文件/第四章/登录/协议与政策.html">忘记密码？</a></div><br>
            <div class="box">
                <input type="reset" class="reset" value="清空">
                <input class="login" type="button" value="登录" onclick="login()">
            </div>
            <div class="agreement">
                <input type="checkbox" id="checkbox"> 阅读并接受
                <a href="HTML5课堂文件/第四章/登录/协议与政策.html">登录协议</a> 和
                <a href="HTML5课堂文件/第四章/登录/协议与政策.html">隐私政策</a>
            </div>
        </form>
    </div>

    <div id="block2" style="display: none;">
        <form class="display_form" action="#" method="post" id="link_login">
            用户名：
            <input class="right" type="text" id="username" placeholder="请输入您的用户名" maxlength="5">
            <br><br>密码：
            <input class="right" type="password" id="password" placeholder="请输入您的密码">
            <div class="register"><a href="#" onclick="toggleBlocks()">已有账号？快速登录</a></div><br>
            <div class="box">
                <input type="reset" class="reset" value="清空">
                <input class="login" type="button" value="注册" onclick="login()">
            </div>
        </form>

    </div>
</body>

</html>